package com.cy.controller;

import com.cy.pojo.Curd;
import com.cy.service.CurdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("/Curd/")
public class CurdController {


    @Autowired
    private CurdService curdService;

    @RequestMapping("CurdFind/{name}")
//    @GetMapping(value = {"CurdFind/{name}"})
    public List<Curd> CurdFind(@PathVariable String name){

        List<Curd> list = curdService.find(name);
        return list;
    }

    @RequestMapping("deleteById/{id}")
    public String deleteById(@PathVariable Integer id){
        curdService.deleteById(id);
        return "delete ok";
    }


    @RequestMapping("insertCurd")
    public String insertCurd(Curd curd){
        curdService.insertCurd(curd);
        return "insert ok";
    }

    @RequestMapping("updateCurd")
    private String updateCurd(Curd curd){
        curdService.updateCurd(curd);
        return "update ok";
    }
}
